<!DOCTYPE html>
<html layout:decorator="wechat/messages/layout">
<head>
    <title>Task List</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <!-- <script src="../../../../resources/js/ckeditor/ckeditor.js" th:src="@{/resources/js/ckeditor/ckeditor.js}"></script> --> 
    <link href="../../../../resources/css/bootstrap-datetimepicker.min.css" rel="stylesheet"  media="screen" th:href="@{/resources/css/bootstrap-datetimepicker.min.css}"/>
</head>
<body>

<div layout:fragment="content">

<div class="container">
<form id="messageForm" action="#" th:action="@{/interface/sendSingleUser}" th:object="${form}" class="well" method="post">

  <div class="form-group">
    <label for="title">标题 </label>
    <input type="text" th:field="*{title}" class="form-control" id="title"  data_check="needInput()"></input>
    <span th:if="${#fields.hasErrors('title')}" th:errors="title">title Error</span>
  </div>
    
   <div class="form-group">
    <label for="description">描述</label>
    <textarea class="form-control"  th:field="*{description}" id="description" style="height: 58px; "></textarea>
    <span th:if="${#fields.hasErrors('description')}" th:errors="description">description Error</span>
  </div>
  
  <div class="form-group">
    <label for="picurl">图片链接 </label>
    <input type="text" th:field="*{picurl}" class="form-control" id="picurl"></input> 640 x 320 px
    <span th:if="${#fields.hasErrors('picurl')}" th:errors="picurl">picurl Error</span>
  </div>
  
  <div class="form-group">
    <label for="url">跳转链接 </label>
    <input type="text" th:field="*{url}" class="form-control" id="url"></input>
    <span th:if="${#fields.hasErrors('url')}" th:errors="url">url Error</span>
  </div>
  
  
<!--  <div class="form-group">
    <label for="content">内容 </label>
    <textarea cols="80" id="*{content}" name="content" rows="10"></textarea>    
  </div>
    
  <script>CKEDITOR.replace( 'content' );</script>  -->
  
  <div class="form-group">
    <label for="user" >测试用户</label>        
    <select name="user" th:field="*{user}" class="form-control">
      <option th:each="user : ${users}" 
          th:value="${user.openid}" 
          th:text="${user.nickname}">user</option>
	</select>
	<span id="refreshUser" class="btn btn-default">刷新测试用户</span>
  </div>
  
   <div class="form-group">  	
  	<span id="singleTest" class="btn btn-default">发给测试用户</span>
  	<span id="allTest" class="btn btn-default" >发送所有用户</span>
  	
  	<script>
  	
  	 $("#singleTest").click(function(){
 		  $("#messageForm")[0].action='<th:block th:text="@{/interface/sendSingleUser2}"></th:block>';
	      $("#messageForm")[0].method = "post";
	      $("#messageForm")[0].submit();
   	});
 	 
 	 $("#allTest").click(function(){
 		$("#messageForm")[0].action='<th:block th:text="@{/interface/sendAllUser2}"></th:block>';
	    $("#messageForm")[0].method = "post";
	    $("#messageForm")[0].submit();	 
  	});   
 	 
 	$("#refreshUser").click(function(){
 		$("#messageForm")[0].action='<th:block th:text="@{/interface/refreshUser2}"></th:block>';
	    $("#messageForm")[0].method = "post";
	    $("#messageForm")[0].submit();	 
  	});
 	
 	 
  	
  	/* $("#singleTest").click(function(){
  		var options = {
  	            url: '<th:block th:text="@{/interface/sendSingleUser}"></th:block>' ,
  	            type: 'post',
  	            dataType: 'html',
  	            data: $("#messageForm").serialize(),
  	            success: function (data) {
						alert(data);
  	            }
  	        };  		
  		$.ajax(options);
    });
  	 
  	 $("#allTest").click(function(){
  		var options = {
  	            url: '<th:block th:text="@{/interface/sendAllUser}"></th:block>' ,
  	            type: 'post',
  	            dataType: 'html',
  	            data: $("#messageForm").serialize(),
  	            success: function (data) {
						alert(data);
  	            }
  	        };  		
  		$.ajax(options);
   	});     */
    </script>
  </div>
</form>

</div>
</div>

</body>
</html>